package com.tubi.ArraySearch;   

public class ArraySearch2 {
    public static void main(String[] args) {
        int[] arr = {22, 1, 11, 5, 712, 112, 33};
        bubbleSort(arr);
        printArr(arr);
    }

    //冒泡排序
    private static void bubbleSort(int[] arr) {
        for (int kj = 0; kj < arr.length-1; kj++) {
            for (int i = 0; i < arr.length-1-kj; i++) {
                if (arr[i] > arr[i + 1]) {
                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
        }
    }

    private static void printArr(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print( arr[i] +" ");
        }
        System.out.println();
    }
}
